package com.shangcheng.goods.dao;

import com.shangcheng.goods.pojo.Sku;
import com.shangcheng.goods.pojo.Spu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface SkuMapper extends Mapper<Sku> {
    @Select("SELECT* FROM tb_sku WHERE NAME LIKE #{name}")
    List<Sku> searchByName(String name);


    /**
     * 商品下订单之后更改库存数量
     *
     * @param id
     * @param num
     * @return
     */
    @Update("update tb_sku set num = num-#{num} where id = #{id} and num > #{num}")
    int decrCount(@Param("id") Long id, @Param("num") Integer num);

}
